package com.ssy.lingxi.logistics.util;

import com.ssy.lingxi.logistics.constant.Constants;
import org.apache.commons.lang.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class LogisticsAddressUtil {

    private LogisticsAddressUtil(){}

    public static String contractFullAddress(String provinceName, String cityName, String districtName, String streetName, String address){
        String pro = StringUtils.isNotEmpty(provinceName) ? provinceName : "";
        String cit = StringUtils.isNotEmpty(cityName) ? cityName : "";
        String dis = StringUtils.isNotEmpty(districtName) ? districtName : "";
        String str = StringUtils.isNotEmpty(streetName) ? streetName : "";
        String add = StringUtils.isNotEmpty(address) ? address : "";

        return pro + cit + dis + str + add;
    }

    /**
     * 校验手机
     * @param phone 手机号
     * @return true, false
     */
    public static boolean validatePhone(String phone) {
        Pattern p = Pattern.compile(Constants.PHONE_REGEX);
        Matcher m = p.matcher(phone);
        return m.matches();
    }

    /**
     * 校验电话
     * @param tel 电话号码
     * @return true, false
     */
    public static boolean validateTel(String tel) {
        Pattern p = Pattern.compile(Constants.TEL_REGEX);
        Matcher m = p.matcher(tel);
        return m.matches();
    }
}
